﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_admin_videoimg_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int v_id = int.Parse(Request["v_id"]);
            txtv_id.Text = v_id.ToString();
            var classid = Request["classid"];
            hidclassid.Value = classid;
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        //上传路径
        string path = Server.MapPath("~/videouploadImg/");

        int classid = int.Parse(Request["classid"]);
        //判断是否上传文件
        if (flImg.HasFile)
        {
            //try
            //{
            //取得文件的扩展名,并转换成小写
            //            string fileExtension = System.IO.Path.GetExtension(this.flImg.FileName).ToLower();

            //            string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + fileExtension;
            //            this.flImg.PostedFile.SaveAs(path + fileName);
            //            int v_id = int.Parse(Request["v_id"]);
            //            Web_video_img img = new Web_video_img();
            //            img.V_id = v_id;
            //            img.Id = txtId.Text;
            //            img.V_img = fileName;
            //            img.V_classid = classid;
            //            Web_video_imgBLL bll = new Web_video_imgBLL();
            //            if (bll.GetElementById(txtId.Text) == null)
            //            {
            //                if (bll.Add(img) > 0)
            //                {
            //                    ClientScript.RegisterStartupScript(GetType(), "a", "alert('添加成功');document.location='admin_video.aspx?classid=" + classid + "';", true);
            //                }
            //                else
            //                {
            //                    ClientScript.RegisterStartupScript(GetType(), "a", "alert('添加失败，请重试1');", true);
            //                }
            //            }
            //            else
            //            {
            //                ClientScript.RegisterStartupScript(GetType(), "a", "alert('已有重复项,请选择修改!');document.location='admin_videoimg_edit.aspx?v_id=" + v_id + "&classid=" + classid + "&id=" + txtId.Text + "';", true);
            //            }
            //        }
            //        catch (Exception ex)
            //        {
            //           ClientScript.RegisterStartupScript(GetType(), "a", "alert('添加失败，请重试');", true);
            //        }
            //    }
            //    else
            //    {
            //        ClientScript.RegisterStartupScript(GetType(), "a", "alert('请选择上传的图片');", true);
            //    }
            //}
            //}
        }
    }
}
